package com.atguigu.jxc.service.impl;

import com.atguigu.jxc.dao.OverflowListDao;
import com.atguigu.jxc.dao.OverflowListGoodsDao;
import com.atguigu.jxc.entity.OverflowList;
import com.atguigu.jxc.entity.OverflowListGoods;
import com.atguigu.jxc.service.OverflowListGoodsService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author tongatong
 * @name OverflowListGoodsServiceImpl
 * @description
 * @date 2021/10/15
 * @time 23:11
 */
@Service
public class OverflowListGoodsServiceImpl implements OverflowListGoodsService {
    @Resource
    private OverflowListDao overflowListDao;
    @Resource
    private OverflowListGoodsDao overflowListGoodsDao;

    @Override
    public void save(OverflowList overflowList, List<OverflowListGoods> overflowListGoodsList, String overflowNumber) {
        if (null != overflowList && !CollectionUtils.isEmpty(overflowListGoodsList)) {
            overflowListDao.insert(overflowList);
            overflowListGoodsList.forEach(overflowListGoods -> overflowListGoods.setOverflowListId(overflowList.getOverflowListId()));
            overflowListGoodsDao.batchInsert(overflowListGoodsList);
        }
    }
}
